﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VehicleManagement.Models;
using VehicleManagement.Codes;

namespace VehicleManagement.ControllersServices
{
    public class DriverManagerService
    {
        public IList<DriverManager> GetAllDriverManager()
        {
            return SqlMapperManager.Instance.Get().QueryForList<DriverManager>("SELECT_ALL_DriverManager", null);
        }

        public object InsertDriverManager(DriverManager driverManager)
        {
            return SqlMapperManager.Instance.Get().Insert("INSERT_DriverManager", driverManager);
        }

        public int UpdateDriverManager(DriverManager drivermanager)
        {
            return SqlMapperManager.Instance.Get().Update("UPDATE_DriverManager", drivermanager);
        }

        public int DeleteDriverManager(int id)
        {
            return SqlMapperManager.Instance.Get().Update("DELETE_DriverManager", id);
        }

        public IList<DriverManager> SearchAllDriverManagers(string name, string telephone, string sex, string company)
        {
            return SqlMapperManager.Instance.Get().QueryForList<DriverManager>("SEARCH_DRIVERMANAGER", new
            {
                Name = name,
                Telephone = telephone,
                Sex = sex,
                Company = company
            });
        }

        public IList<DriverManager> SearchAllDriverManagers(string name,
            string telephone, string sex, int page, int max,string company)
        {
            return SqlMapperManager.Instance.Get().QueryForList<DriverManager>("SEARCH_DRIVERMANAGER", new
            {
                Name = name,
                Telephone = telephone,
                Sex = sex,
                Company = company
            },page,max);
        }
    }
}